package com.example.administrator.test2;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {
    private String etname;
    private String etpassword;
    private EditText  name;
    private EditText  password;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button mbotton = (Button) findViewById(R.id.button);
        name=(EditText)findViewById(R.id.name) ;
        password=(EditText)findViewById(R.id.password) ;
        mbotton.setOnClickListener(new Button.OnClickListener(){
            public void onClick(View v){
                etname = name.getText().toString();
                etpassword = password.getText().toString();
                if ("123456".equals(etname)&&"123456".equals(etpassword)){
                    Intent intent = new Intent();
                    intent.setClass(MainActivity.this, function.class);
                    startActivity(intent);
                }
                else{
                    Intent intent=new Intent();
                    intent.setClass(MainActivity.this, error.class);
                    startActivity(intent);
                }
            }
        });
    }
}
